Performance analysis of a parallel application is more challenging
than performance analysis of a sequential application. A parallel
application has more moving parts, such as tasks, threads, the thread
pool, and synchronization. Therefore, Microsoft created the Concurrency
Visualizer as an advanced profiler and included this powerful tool in
Visual Studio 2010. The Concurrency Visualizer provides a wide
assortment of charts and reports to help you visualize and analyze the
performance of your parallel application.
The Concurrency Visualizer is feature rich. This section contains
only an overview of this comprehensive tool, but you can find detailed
articles and videos on this subject on MSDN. For example, see
“Concurrent Visualization Techniques in the VS2010 Profiler,” by Phil
Pennington.
The Concurrency Visualizer is an Event Tracing for Windows (ETW)
consumer and receives kernel-level data from low-level tracing in the
operating system. ETW provides several benefits. It’s implemented as
part of the operating system kernel and not the user-mode application.
Because it is non-invasive, ETW has minimal impact on your application.
ETW is a systemwide resource and provides a single tracing model that
all developers can depend on. As an ETW subscriber, the Concurrency
Visualizer has certain restrictions:
-
Visual Studio must have administrative privileges to launch the Concurrency Visualizer.
-
By default, 64-bit applications cannot view a complete stack trace in
the Concurrency Visualizer. You must set the Disable Paging Executive
flag in the registry. Run the following command from the command line to
update the registry appropriately.
REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Memory
Management" -v DisablePagingExecutive -d 0x1 -t REG_DWORD -f
After updating the registry key, you must reboot the system before attempting to use the Concurrency Visualizer.
-
ETW can consume considerable storage, which might cause data loss and
an error when you are using the Concurrency Visualizer. Increase the
ETW buffer size to resolve this problem.
To start the Concurrency Visualizer, select Launch Performance Wizard
from the Analyze menu to begin profiling. In the Performance Wizard
dialog box, shown here, you select the Concurrency option and the
Visualize The Behavior Of A Multithreaded Application check box.
Then proceed to the next screen. In this screen, you select the
project you intend to profile. If you want to start an executable, you
can choose the An Executable (.EXE File) option. When you choose this,
you’ll see a different dialog box in which you can browse to the target
executable.
The next window is essentially a confirmation screen. Here you click
the Finish button to accept the current settings and begin profiling.
Clicking the Previous button allows you to revisit settings and make
changes.
Your application starts, and trace data is collected as the application runs. Select the Stop Profiling
link to stop performance profiling. The data analysis begins when the
profiling stops. Be patient, because the analysis might take some time.
When the analysis completes, the Concurrency Visualizer presents three
views: CPU Utilization, Threads, and Cores.
The Performance Explorer opens automatically and provides an overview
of the profiling sessions. You can run multiple profiling sessions and
save them to individual files with a .psess extension. Each session
appears in the Performance Explorer window, shown here.
From the command line, you can collect data for the Concurrency
Visualizer by using the Visual Studio Profiler. This allows you to
automate the process, which is especially helpful on production machines
where Visual Studio is not installed.